

%--------------------------------------
% 	       章节操纵      
%--------------------------------------
\usepackage[center]{titlesec}%chapter1修改为第1章
\titleformat{\chapter}{\raggedright\Huge\bfseries}{第\,\thechapter\,章}{1em}{}
\titleformat{\section}{\raggedright\Large\bfseries}{\,\thesection\,}{1em}{}
\titleformat{\subsection}{\raggedright\large\bfseries}{\,\thesubsection\,}{1em}{}

%--------------------------------------
% 	       页面与标题式样       
%--------------------------------------


\usepackage{geometry} % Required for adjusting page dimensions and margins 这玩意一定要在fancyhdr之前导入，不然会产生页眉长度错误！！！！

\setlength{\parskip}{0.5\baselineskip} %段落间距

\geometry{
	paper=a4paper, % Paper size, change to letterpaper for US letter size
	%papersize={185mm,260mm}, % specify paper size by (width,height)
	top=2cm, % Top margin
	bottom=2cm, % Bottom margin原来1.5cm
	left=1.8cm, % Left margin
	right=1.8cm, % Right margin
	headheight=13pt, % Header height
	footskip=1.4cm, % Space from the bottom margin to the baseline of the footer
	headsep=10pt, % Space from the top margin to the baseline of the header
	%showframe, % Uncomment to show how the type block is set on the page
}


%----------------------------------------------------------------------------------------
%	页眉和脚注
%----------------------------------------------------------------------------------------

\usepackage{fancyhdr} % Required for header and footer configuration

\pagestyle{fancy} % Enable the custom headers and footers

\renewcommand{\chaptermark}[1]{\markboth{\sffamily\normalsize\bfseries\chaptername\ \thechapter.\ #1 }{}} % Styling for the current chapter in the header
\renewcommand{\sectionmark}[1]{\markright{\sffamily\normalsize\thesection\hspace{5pt}#1}{}} % Styling for the current section in the header


\fancyhead[LE,RO]{\sffamily\normalsize\thepage} % Styling for the page number in the header
\fancyhead[LO]{\rightmark} % Print the nearest section name on the left side of odd pages
\fancyhead[RE]{\leftmark} % Print the current chapter name on the right side of even pages
%\fancyfoot[RE]{\tiny{肖桐\ 朱靖波}}
%O-odd page,E-even page,R-right area,L-left area,C-center area
%\fancyfoot[C]{\thepage} % Uncomment to include a footer底部中间页码

\renewcommand{\headrulewidth}{0.5pt} % Thickness of the rule under the header

\fancypagestyle{plain}{% Style for when a plain pagestyle is specified
	\fancyhead{}\renewcommand{\headrulewidth}{0pt}%
}

% Removes the header from odd empty pages at the end of chapters
\makeatletter
\renewcommand{\cleardoublepage}{
	\clearpage\ifodd\c@page\else
	\hbox{}
	\vspace*{\fill}
	\thispagestyle{empty}
	\newpage
	\fi}

% 让页眉足够长，但是偶数页页眉会变短两格？
%\addtolength{\headwidth}{\marginparsep}
%\addtolength{\headwidth}{\marginparwidth}




%--------------------------------------
% 	       段落样式       
%--------------------------------------

\usepackage{indentfirst} 
%\setlength{\parindent}{2em} 
%如果某一段不需要缩进，可以使用 \noindent
%--------------------------------------
% 	       特殊字符       
%--------------------------------------
\usepackage{pifont} % 圆圈序号用的 \ding来自于这里。
\usepackage{bbding}
%--------------------------------------
% 	       图片样式       
%--------------------------------------

\usepackage{graphicx}
%--------------------------------------
% 	       表格样式       
%--------------------------------------


\usepackage{tabu}                     % 表格插入
\usepackage{multirow}                 % 一般用以设计表格，将所行合并
\usepackage{multicol}                 % 合并多列
\usepackage{multirow}                % 合并多行
\usepackage{float}                    % 图片浮动
\usepackage{makecell}                 % 三线表-竖线
\usepackage{booktabs}                 % 三线表-短细横线
\usepackage{colortbl}
%--------------------------------------
% 	       代码样式       
%--------------------------------------
\usepackage{xcolor}
\usepackage{listings}
\lstset{
	language=Python,
	%frame=shadowbox,
	basicstyle=\ttfamily,
	columns=fixed,
	extendedchars=true,
	breaklines=true,
	tabsize=4,
	prebreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\hookleftarrow}},
	%--------------边框
	frame=lines,
	framexleftmargin=0.9em, % 设置边框与代码的距离
	%-----------------边框结束
	%showtabs=false,
	showspaces=false,
	showstringspaces=false,
	keywordstyle=\color{blue},
	commentstyle=\color[rgb]{0.133,0.545,0.133},
	stringstyle=\color[rgb]{01,0,0},
	%------------行号
	numbers=left,
	numberstyle=\small,
	stepnumber=1,
	numbersep=0em, % 设置行号的具体位置
	%-----------行号结束
	captionpos=t,
	float,
	escapeinside={\%*}{*)},
	morekeywords = {Func},
	keywords={begin,end,while,if,else,elif,return,Var},
	xleftmargin=2em,%控制左侧缩进两格
}
%-------------------------------

\usepackage{tcolorbox}
%--------------------------------------
% 	 自定义枚举环境，如(1)
%--------------------------------------
\usepackage{enumerate}
\usepackage{enumitem} %用于enumerate环境缩进，配合itemindent
\setlist[enumerate,1]{font=\textup,
	leftmargin=3em,labelsep=1.5mm,topsep=0mm,itemsep=-0.8mm}
\setlist[enumerate,2]{label=(\alph*),font=\textup,
	leftmargin=7mm,labelsep=1.5mm,topsep=-0.8mm,itemsep=-0.8mm}
%--------------------------------------
% 	 算法
%--------------------------------------
\usepackage[ruled,linesnumbered]{algorithm2e}
%--------------------------------------
% 	 数学公式
%--------------------------------------
\usepackage{amsmath}



%--------------------------------------
% 	 删除线
%--------------------------------------
\usepackage{cancel}

%--------------------------------------
% 	 例子,定理和定义等自定义计数器   
%--------------------------------------
\usepackage{amsmath,amsfonts,amssymb,amsthm} % For math 
%计数器部分

\newtheoremstyle{blacknumex}% Theorem style name
{5pt}% Space above
{5pt}% Space below
{\normalfont}% Body font
{} % Indent amount
{\small\bf\sffamily}% Theorem head font
{\;}% Punctuation after theorem head
{0.25em}% Space after theorem head
{\small\sffamily{\tiny\ensuremath{}}\nobreakspace\thmname{#1}\nobreakspace\thmnumber{\@ifnotempty{#1}{}\@upn{#2}}% Theorem text (e.g. Theorem 2.1)\blacksquare去除
	\thmnote{\nobreakspace\the\thm@notefont\sffamily\bfseries---\nobreakspace#3.}}% Optional theorem note

\newtheoremstyle{blacknumbox} % Theorem style name
{0pt}% Space above
{0pt}% Space below
{\normalfont}% Body font
{}% Indent amount
{\small\bf\sffamily}% Theorem head font
{\;}% Punctuation after theorem head
{0.25em}% Space after theorem head
{\small\sffamily\thmname{#1}\nobreakspace\thmnumber{\@ifnotempty{#1}{}\@upn{#2}}% Theorem text (e.g. Theorem 2.1)
	\thmnote{\nobreakspace\the\thm@notefont\sffamily\bfseries---\nobreakspace#3.}}% Optional theorem note

% Non-boxed/non-framed environments
\newtheoremstyle{ocrenum}% Theorem style name
{5pt}% Space above
{5pt}% Space below
{\normalfont}% Body font
{}% Indent amount
{\small\bf\sffamily\color{ocre}}% Theorem head font
{\;}% Punctuation after theorem head
{0.25em}% Space after theorem head
{\small\sffamily\color{ocre}\thmname{#1}\nobreakspace\thmnumber{\@ifnotempty{#1}{}\@upn{#2}}% Theorem text (e.g. Theorem 2.1)
	\thmnote{\nobreakspace\the\thm@notefont\sffamily\bfseries\color{black}---\nobreakspace#3.}} % Optional theorem note
\makeatother


\newcounter{dummy}
\numberwithin{dummy}{section}

\newtheorem{theoremeT}[dummy]{Theorem}
\newtheorem{problem}{Problem}[chapter]
\newtheorem{exerciseT}{Example}[chapter]
\theoremstyle{blacknumex}
\newtheorem{exampleT}{例}[chapter]
\theoremstyle{blacknumbox}
\newtheorem{vocabulary}{Vocabulary}[chapter]
\newtheorem{definitionT}{定义}[chapter]
\newtheorem{corollaryT}[dummy]{Corollary}
\theoremstyle{ocrenum}
\newtheorem{proposition}[dummy]{Proposition}
% Creates an environment for each type of theorem and assigns it a theorem text style from the "Theorem Styles" section above and a colored box from above
\newenvironment{theorem}{\begin{theoremeT}}{\end{theoremeT}}
\newenvironment{exercise}{\begin{eBox}\begin{exerciseT}}{\hfill{\color{ocre}\tiny\ensuremath{\blacksquare}}\end{exerciseT}\end{eBox}}				
\newenvironment{definition}{\begin{definitionT}}{\end{definitionT}}	
%\newenvironment{example}{\begin{exampleT}}{\hfill{\tiny\ensuremath{\blacksquare}}\end{exampleT}}	
\newenvironment{example}{\begin{exampleT}}{\end{exampleT}}	
\newenvironment{corollary}{\begin{cBox}\begin{corollaryT}}{\end{corollaryT}\end{cBox}}	

%用于取消def和example后面多余的. 上帝保佑
\usepackage{xpatch}
\makeatletter
\xpatchcmd{\@thm}{\thm@headpunct{.}}{\thm@headpunct{}}{}{}
\makeatother


%-------------------------------------------------
%						图表
%-------------------------------------------------
\usepackage{array}
\usepackage[UTF8]{ctex}
\usepackage{standalone}
\usepackage{tikz-cd}
\usepackage{tikz,graphicx,subfig,caption} % Required for drawing custom shapes
\usetikzlibrary{fit,matrix,chains,arrows,shapes,positioning,arrows.meta,chains,shadows,shapes.callouts,decorations.text,shapes.symbols,shapes.misc, positioning,decorations.pathreplacing,calc}
\makeatletter
\tikzset{reset join/.code={\def\tikz@after@path{}}}
\makeatother
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\usepackage[justification=centering]{caption}%强制图片居中


%----------------------------------------------------------------
%		章节名称
%-------------------------------------------------------------
%%%%%%%%%%%chapter 16---------------------------------------
\usetikzlibrary{calc,fadings,decorations.pathreplacing}
\usepackage{verbatim}

\newcommand{\mychapter}[1]{第\ref{#1}章}%chapter用
\newcommand{\mysection}[1]{第\ref{#1}节}%section、subsection、subsubsection用
\newcommand\chapterone{第一章}%*
\newcommand\chaptertwo{第二章}%*
\newcommand\chapterthree{第三章}
\newcommand\chapterfour{第四章}
\newcommand\chapterfive{第五章}%*
\newcommand\chaptersix{第六章}
\newcommand\chapterseven{第七章}%*
\newcommand\chaptereight{第八章}
\newcommand\chapternine{第九章}%*
\newcommand\chapterten{第十章}%*
\newcommand\chaptereleven{第十一章}
\newcommand\chaptertwelve{第十二章}%*
\newcommand\chapterthirteen{第十三章}
\newcommand\chapterfourteen{第十四章}
\newcommand\chapterfifteen{第十五章}
\newcommand\chaptersixteen{第十六章}
\newcommand\chapterseventeen{第十七章}
\newcommand\chaptereighteen{第十八章}%*

\newcommand\funp{}%函数P等使用，空是斜体，textrm是加粗
\newcommand\vectorn{\textbf}%向量N等使用${\vectorn{\emph{s}}}$
\def\mathbi#1{\textbf{\em #1}}%向$量N等使用\mathbi{s}$
\newcommand\seq{}%序列N等使用
